/*
 * @Date: 2025-06-13 10:50:10
 * @Auth: 463997479@qq.com
 * @LastEditors: 463997479@qq.com
 * @LastEditTime: 2025-09-27 23:46:35
 * @FilePath: \corpus\src\pages\resourceManagement\fileList\component\Analysis\index.tsx
 */
import { Form, Modal } from 'antd';
import type React from 'react';
import { useEffect } from 'react';
import hooks from '../../hooks';

const EditAngent: React.FC = () => {
  const {
    setAnalysisVisible,

    parseBatchContent,
    analysisVisible,
    formAnalysis,
    selectedRows,
  } = hooks.useContainer();
  const title = '解析';

  const handleSubmit = () => {
    formAnalysis.validateFields().then((vals) => {
      const method = parseBatchContent;
      method.run({
        ...vals,
        ids: selectedRows.map((item) => item.id),
      });
    });
  };

  useEffect(() => {
    if (analysisVisible && selectedRows) {
      formAnalysis.setFieldValue('openProperty', selectedRows[0]?.openProperty);
      formAnalysis.setFieldValue('sensitiveLevel', selectedRows[0]?.sensitiveLevel);
    } else {
      formAnalysis.resetFields();
    }
  }, [selectedRows, analysisVisible]);
  return (
    <Modal
      width={600}
      title={title}
      open={analysisVisible}
      onCancel={() => {
        formAnalysis.resetFields();
        setAnalysisVisible(false);
      }}
      onOk={handleSubmit}
      confirmLoading={parseBatchContent?.loading}
    >
      <Form labelCol={{ span: 4 }} form={formAnalysis}>
        <p>是否确认解析？</p>
      </Form>
    </Modal>
  );
};

export default EditAngent;
